<?php

class Tree{
    static public $treeList=array();  //存放无限极分类结果

    public function create($data,$pid=0){   //初始化
        foreach($data as $key=>$value){   //循环
           if($value['pid']==$pid){
               self::$treeList[]=$value;
               unset($data[$key]);
               self::create($data,$value['id']);
           }
        }
        return self::$treeList;  //self::解决静态问题
    }
}